package com.bishe.tax.controller.sys;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.bishe.tax.service.FileUploadService;
import com.bishe.tax.utils.AjaxResult;

@Controller
@RequestMapping("file")
public class FileController {

	@Autowired
	private FileUploadService fileUploadService;

	@RequestMapping("upload")
	@ResponseBody
	public AjaxResult upload(MultipartFile upload) {
		try {
			String path = fileUploadService.upLoadFile(upload);
			Map<String, Object> map = new HashMap<>();
			map.put("path", path);
			return AjaxResult.success(map);
		} catch (Exception e) {
			return AjaxResult.error();
		}
	}
}
